<template>
	<!-- 课程列表-->
	<view class="wm">
		<block v-if="course.length > 0">
			<navigator hover-class="none" class="school" v-for="(item,i) in course" :key="item.id" :url="'/subpkg/question_list/question_list?schoolid='+queryObj.schoolid+'&questionwayid='+queryObj.questionwayid+'&questiontypeid='+queryObj.questiontypeid+'&questioncourseid='+item.id">
				<view class="school_info">
					<view class="school_name">{{item.name}}</view>
				</view>
				<view class="right">
					<uni-icons type="right" color="#515151"></uni-icons>
				</view>
			</navigator>
		</block>
		<block v-else>
			<no-data></no-data>
		</block>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				queryObj:{
					schoolid:0,
					pageNumber:1,
					length:20,
					questionwayid:0,
					questiontypeid:0,
				},
				course:[],
				isloading:false,
				total:0,
		
			}
		},
		onLoad(option){
			this.queryObj.schoolid = option.schoolid || 0;
			this.queryObj.questionwayid = option.questionwayid || 0;
			this.queryObj.questiontypeid = option.questiontypeid || 0;
			this.getCourse();
		},
		computed:{
			
		},
		methods: {
			async getCourse(){
				//打开节流阀
				this.isloading = true;
				const {data:res} = await uni.$http.post("Questions/getAllQuestioncourse",this.queryObj);
				this.isloading = false;
				//请求失败
				if(res.meta.status !== 1) return uni.$showMsg();
				//请求成功
				
				this.course = [...this.course,...res.data];
				this.total = res.total;
				
			}
		},
		/**
		 * 学校列表上拉加载更多
		 */
		onReachBottom(){
			//根据节流阀加载数据
			if(this.isloading) return;
			//让页码值自增+1
			this.queryObj.pageNumber++
			//如果当前pageNumber大于了最大页数则不加载
			if(this.queryObj.pageNumber <= this.total){
				this.getSchool(); //请求数据
			}
		},
	}
</script>

<style lang="scss">
@import "../../static/list.scss";

</style>
